﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Collections;
using SmartMD.Manager.Utils;
using SmartMD.DataModel.Entity;
using SmartMD.Manager.Common;

namespace SmartMD.Manager.Specimens.Store
{
    /// <summary>
    /// Interaction logic for NewSpecDialog.xaml
    /// </summary>
    public partial class NewSpecDialog : Window
    {
        private StoreSpecPanel _owner = null;
        public NewSpecDialog(StoreSpecPanel owner)
        {
            _owner = owner;
            InitializeComponent();
        }

        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            SpecInfo spec = new SpecInfo();
            spec.Id = System.Guid.NewGuid().ToString();
            spec.FollowUpDate = System.DateTime.Now;
            
            string speccode = (txtSpecType.SelectedItem as ComboBoxValueItem).Value.ToString();
            spec.SpecType = speccode;

            spec.State = DataModel.RecordState.Added;
            this._owner.ucSpecStoreEdit.DataSource = spec;
            spec.No = "第" + (this._owner.ucSpecList.specInfoList.Count+1).ToString() + "份";
            this._owner.ucSpecList.AddItem(spec);
           
            this._owner.ucSpecStoreEdit.IsEnabled = true;
            this._owner.ucSpecStoreEdit.BtnSearchSite.IsEnabled = true;
            //标识未保存状态
            this._owner.isSaved = false;
            this.Close();
        }

        private Hashtable _cmbHashtable = new Hashtable();
        private void txtSpecType_Initialized(object sender, EventArgs e)
        {
            _cmbHashtable.Add("标本类型", sender);
            ComboxUtil.InitializeComboxByDict(sender, "标本类型");
        }

    }
}
